<!DOCTYPE html>
<html>


<!-- Mirrored from www.gzsxt.cn/theme/hplus/table_basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:20:01 GMT -->
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>绿地中央广场综合物业办公系统 - 基础表格</title>
    <meta name="keywords" content="综合办公系统">
    <meta name="description" content="综合办公系统">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/select/bootstrap-select.min.css" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper2 wrapper-content2 animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-3 col-sm-offset-2 text-right">
                    <h3><small>搜索条件:</small></h3>
                </div>
                <div class="col-sm-2">
                    <select class="selectpicker form-control">
                        <option value="0">选择类型</option>
                        <option value="1">项目名称</option>
                        <option value="2">项目经理</option>
                    </select>
                </div>

                <div class="col-sm-3">
                    <div class="input-group">
                        <input type="text" placeholder="请输入关键词" class="input-sm form-control">
                        <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-primary"><i
                                                class="fa fa-search"></i>搜索</button>
                                    </span>
                    </div>
                </div>
                <div class="col-sm-2 text-right">
                    <a href="save-employee.html" class="btn btn-sm btn-primary" type="button"><i
                            class="fa fa-plus-circle"></i> 添加员工</a>
                </div>
            </div>
            <div class="hr-line-dashed2"></div>
            <div class="table-responsive">
                <table class="table table-striped list-table">
                    <thead>
                    <tr>
                        <th>选择</th>
                        <th>序号</th>
                        <th>姓名</th>
                        <th>用户名</th>
                        <th>性别</th>
                        <th>年龄</th>
                        <th>电话</th>
                        <th>入职时间</th>
                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>

            <div class="row">
                <div class="col-sm-5">
                    <button class="btn btn-sm btn-primary" type="button"><i class="fa fa-check-square-o"></i> 全选
                    </button>
                    <button class="btn btn-sm btn-primary" type="button"><i class="fa fa-square-o"></i> 反选</button>
                    <button class="btn btn-sm btn-primary" type="button"><i class="fa fa-times-circle-o"></i> 删除
                    </button>
                    <a class="btn btn-sm btn-primary toexcel" href="/employee/downloadExcel?pageNum=1"><i class="fa fa-table"></i> 导出Excel
                    </a>
                </div>
                <div class="col-sm-7 text-right pageList">

                </div>
            </div>

        </div>
    </div>
</div>
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<script src="js/plugins/select/bootstrap-select.min.js"></script>
<script src="js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="js/url.js"></script>
<script src="js/page.js"></script>
<script>

    function loadData(pageNum) {
        $("tbody").html("");
        $.getJSON("/employee/list", {"pageNum": pageNum}, function (response) {
            globalPageNum = response.pageNum;
            globalSize = response.size;
            $(response.list).each(function () {
                let $str = `<tr>
                            <td><input  type="checkbox" value="` + this.eid + `"></td>
                            <td>` + this.eid + `</td>
                            <td>` + this.ename + `</td>
                            <td>` + this.username + `</td>
                            <td>` + this.esex + `</td>
                            <td>` + this.eage + `</td>
                            <td>` + this.telephone + `</td>
                            <td>` + this.hiredate + `</td>
                            <td class="text-right">
                            <a href="show-employee.html?eid=`+this.eid+`" class="btn btn-primary btn-xs"><i class="fa fa-eye"></i>查看</a>
                               <a href="update-employee.html?eid=` + this.eid + `" class="btn btn-primary btn-xs"><i class="fa fa-edit"></i>编辑</a>
                                  <button id="`+this.eid+`" class="btn btn-danger btn-xs btndel"><i class="fa fa-close"></i>删除</button>
                            </td>
                        </tr>`;
                $("tbody").append($str);
            })
            page(response);
        })
    }

    function setPage(pageNum){
        $(".toexcel").prop("href","/employee/downloadExcel?pageNum="+pageNum);
    }
    $(document).ready(function () {
        loadData();

        $("body").on("click",".btndel",function () {
            let id = $(this).prop("id");
            swal({
                title: "您确定要删除这条信息吗",
                text: "删除后将无法恢复，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "删除",
                closeOnConfirm: false,
                cancelButtonText: "取消",
            }, function () {//此函数是点击删除执行的函数
                $.post("/employee/remove",{"id":id},function (response) {
                    if (response == "success") {
                        swal("删除成功", "删除成功","success");
                        if (globalSize==1){
                            globalPageNum = globalPageNum -1;
                        }
                        loadEmployee(globalPageNum);
                    }else {
                        swal("删除失败", "删除成功...","error");
                    }
                },"text")
            });
        });
    });
</script>

</body>


</html>
    